package com.neuedu.servlet;

import java.io.IOException;
import java.util.List;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.neuedu.domain.Articletype;
import com.neuedu.domain.Userinfo;
import com.neuedu.service.ArticleService;
import com.neuedu.service.impl.ArticleServiceImpl;

@WebServlet("/go/update")
public class ArticleGoUpdateServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String artid = request.getParameter("id");
		System.out.println(artid);
		ArticleService as = new ArticleServiceImpl();
		Map<String,Object> artmap = as.upArticleDetail(Integer.parseInt(artid));
		System.out.println(artmap);
		request.setAttribute("artmap", artmap);
		request.setAttribute("edit_id", artid);
		Userinfo userinfo = (Userinfo)request.getSession().getAttribute("login_user");
		List<Articletype> typelist = as.loadArticleType(userinfo);
		request.setAttribute("typelist", typelist);
		request.getRequestDispatcher("/jsp/tie/add.jsp").forward(request, response);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}
